/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ComponentsUI.java
 *
 * Created on 11 1, 11, 7:52:42 PM
 */
package introsemp;

import java.awt.event.*;
import javax.swing.*;

/**
 *
 * @author Marit
 */
public class ComponentsUI extends javax.swing.JPanel {

    /** Creates new form ComponentsUI */
    JFrame frame;
    int usertype;
    public ComponentsUI(int usertype) {
        initComponents();
        this.usertype = usertype;
        JLabel bg = new JLabel();
        if (usertype==0)
            bg.setIcon(new ImageIcon("Images\\manage components.png"));
        if (usertype==1)
            bg.setIcon(new ImageIcon("Images\\admin components.png"));
        
        bg.setSize(930, 686);
        add(bg);
        bg.setVisible(true);
        
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        componentName = new javax.swing.JTextField();
        componentPercent = new javax.swing.JTextField();
        ok = new javax.swing.JButton();
        cancel = new javax.swing.JButton();
        addComponent = new javax.swing.JButton();
        editComponent = new javax.swing.JButton();
        subjectLabel = new javax.swing.JLabel();
        subjectList = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        Button2 = new javax.swing.JButton();
        Button3 = new javax.swing.JButton();
        Button1 = new javax.swing.JButton();
        logoutButton = new javax.swing.JButton();

        jTable1.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Component Name", "Percentage"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.Float.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.setGridColor(new java.awt.Color(153, 153, 153));
        jTable1.setRowHeight(20);
        jScrollPane1.setViewportView(jTable1);

        jLabel1.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel1.setText("Name:");

        jLabel2.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel2.setText("Percent:");

        componentName.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N

        componentPercent.setFont(new java.awt.Font("Verdana", 0, 12));

        ok.setFont(new java.awt.Font("Verdana", 0, 12));
        ok.setText("OK");

        cancel.setFont(new java.awt.Font("Verdana", 0, 12));
        cancel.setText("Cancel");

        addComponent.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N
        addComponent.setIcon(new javax.swing.ImageIcon(getClass().getResource("/introsemp/add.png"))); // NOI18N
        addComponent.setText("Add Component");
        addComponent.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                addComponentMouseReleased(evt);
            }
        });
        addComponent.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addComponentActionPerformed(evt);
            }
        });

        editComponent.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N
        editComponent.setIcon(new javax.swing.ImageIcon(getClass().getResource("/introsemp/edit.png"))); // NOI18N
        editComponent.setText("Edit Component");
        editComponent.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                editComponentMouseReleased(evt);
            }
        });
        editComponent.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editComponentActionPerformed(evt);
            }
        });

        subjectLabel.setFont(new java.awt.Font("Verdana", 0, 13)); // NOI18N
        subjectLabel.setText("View:");

        subjectList.setFont(new java.awt.Font("Verdana", 0, 13)); // NOI18N
        subjectList.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "English", "Filipino", "Mathematics", "Science" }));

        jLabel3.setFont(new java.awt.Font("Verdana", 0, 15)); // NOI18N
        jLabel3.setText("Component Details");

        Button2.setContentAreaFilled(false);
        Button2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Button2.setFocusPainted(false);
        Button2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button2ActionPerformed(evt);
            }
        });

        Button3.setContentAreaFilled(false);
        Button3.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Button3.setFocusPainted(false);
        Button3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button3ActionPerformed(evt);
            }
        });

        Button1.setContentAreaFilled(false);
        Button1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Button1.setFocusPainted(false);
        Button1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button1ActionPerformed(evt);
            }
        });

        logoutButton.setFont(new java.awt.Font("Verdana", 0, 13)); // NOI18N
        logoutButton.setText("Log out");
        logoutButton.setContentAreaFilled(false);
        logoutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(40, 40, 40)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(Button1, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(Button2, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(Button3, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(44, 44, 44)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(subjectLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(subjectList, javax.swing.GroupLayout.PREFERRED_SIZE, 281, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(40, 40, 40)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1)
                            .addComponent(componentName, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2)
                            .addComponent(componentPercent, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(1, 1, 1)
                                .addComponent(ok, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(8, 8, 8)
                                .addComponent(cancel, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(12, 12, 12)
                                .addComponent(addComponent, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(12, 12, 12)
                                .addComponent(editComponent, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(60, 60, 60)
                        .addComponent(logoutButton)))
                .addContainerGap(47, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(144, 144, 144)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(5, 5, 5)
                                .addComponent(subjectLabel))
                            .addComponent(subjectList, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 444, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(153, 153, 153)
                        .addComponent(jLabel3)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel1)
                        .addGap(7, 7, 7)
                        .addComponent(componentName, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(jLabel2)
                        .addGap(7, 7, 7)
                        .addComponent(componentPercent, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(23, 23, 23)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ok, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cancel, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(70, 70, 70)
                        .addComponent(addComponent, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(5, 5, 5)
                        .addComponent(editComponent, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(53, 53, 53))
            .addGroup(layout.createSequentialGroup()
                .addGap(150, 150, 150)
                .addComponent(Button1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(Button2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(7, 7, 7)
                .addComponent(Button3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 360, Short.MAX_VALUE)
                .addComponent(logoutButton)
                .addGap(24, 24, 24))
        );
    }// </editor-fold>//GEN-END:initComponents

    public void remove() {
        frame.remove(this);
    }
    public void setFrame(JFrame frame) {
        this.frame = frame;
        frame.add(this);
        frame.validate();
        frame.setSize(930, 686);
    }
private void addComponentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addComponentActionPerformed
    JDialog dbox = new JDialog();
    JOptionPane.showMessageDialog(dbox,"Function is not yet available.\n"+" ");
        // TODO add your handling code here:
}//GEN-LAST:event_addComponentActionPerformed
private void editComponentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editComponentActionPerformed
    JDialog dbox = new JDialog();
    JOptionPane.showMessageDialog(dbox,"Function is not yet available.\n"+" ");
    // TODO add your handling code here:
}//GEN-LAST:event_editComponentActionPerformed

private void addComponentMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_addComponentMouseReleased
//    dialogBoxLoader();// TODO add your handling code here:
}//GEN-LAST:event_addComponentMouseReleased
private void editComponentMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_editComponentMouseReleased
//    dialogBoxLoader();// TODO add your handling code here:
}//GEN-LAST:event_editComponentMouseReleased

private void Button2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button2ActionPerformed
    remove();
    if (usertype==0) {
        GradeBreakdownUI a = new GradeBreakdownUI(usertype);
        a.setFrame(frame);
    }
    if (usertype==1) {
        FacultyUI f = new FacultyUI();
        f.setFrame(frame);
    }
    // TODO add your handling code here:
}//GEN-LAST:event_Button2ActionPerformed

private void Button3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button3ActionPerformed
    remove();
    if (usertype==0) {
        ClassUI c = new ClassUI();
        c.setFrame(frame);
    }
    if (usertype==1) {
        GradeBreakdownUI g = new GradeBreakdownUI(1);
    g.setFrame(frame);
        
    }
    // TODO add your handling code here:
}//GEN-LAST:event_Button3ActionPerformed

private void Button1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button1ActionPerformed
    remove();
    if (usertype==0) {
        GradesUI g = new GradesUI(0);
        g.setFrame(frame);
    }
    if (usertype==1) {
        SectionsUI s = new SectionsUI();
        s.setFrame(frame);}
    // TODO add your handling code here:
}//GEN-LAST:event_Button1ActionPerformed

private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutButtonActionPerformed
    JDialog dbox = new JDialog();
    dbox.setSize(400,250);
    int response = JOptionPane.showConfirmDialog(
                    dbox, "Are you sure you want to log out?", " ", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
            if (response == JOptionPane.YES_OPTION ) {
                dbox.dispose();
                System.exit(0);
            } else if (response == JOptionPane.NO_OPTION ) {
                dbox.dispose();
            }    // TODO add your handling code here:
}//GEN-LAST:event_logoutButtonActionPerformed

public boolean intCheck(String what) {
        boolean tf = false;
        for (int i = 0; what.length()>i; i++) {
            for (char j='A'; 'z'>j; j++) {
                if (what.charAt(i)==j)
                tf = true;
            }
        }
        return tf;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Button1;
    private javax.swing.JButton Button2;
    private javax.swing.JButton Button3;
    private javax.swing.JButton addComponent;
    private javax.swing.JButton cancel;
    private javax.swing.JTextField componentName;
    private javax.swing.JTextField componentPercent;
    private javax.swing.JButton editComponent;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JButton logoutButton;
    private javax.swing.JButton ok;
    private javax.swing.JLabel subjectLabel;
    private javax.swing.JComboBox subjectList;
    // End of variables declaration//GEN-END:variables
}
